<?php

namespace App\Http\Middleware;

use Closure;
use Nette\Mail\Message;
use Nette\Mail\SmtpMailer;

class EmailMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
         $rs = $next($request); 


        $mail = new Message;
        $mail->setFrom('kaka <18511417652@163.com>')
            ->addTo($request->input('email'))
            ->setSubject('哈哈哈哈')
            ->setBody("投票"); 
            $mailer = new SmtpMailer([
                'host' => 'smtp.163.com',
                'username' => '18511417652',
                'password' => 'jzl0500',
        ]);
        $mailer->send($mail);
       return $rs; 
    }

}
 